﻿using System;

namespace Might.Infrastructure.ModelicaDOM {

    /// <summary>
    /// Used when proper mapping can not be found
    /// </summary>
    public class AttributeException : Exception{
        
        /// <summary>
        /// Public constructor
        /// </summary>
        /// <param name="message">Exception message</param>
        public AttributeException(string message) : base(message) { }

    }
    
    /// <summary>
    /// Determines the source item in ast which will be mapped into entity marked with this attribute.
    /// Target entity may be object or property of the object.
    /// </summary>
    public class MappingAttribute : Attribute {

        /// <summary>
        /// Public constructor
        /// </summary>
        /// <param name="source"></param>
        public MappingAttribute(string source) {
            this._source = source;
        }
                
        private string _source;
        
        /// <summary>
        /// Name of the source entity
        /// </summary>
        public string Source{
            get{return this._source;}
            set{this._source = value;}
        }
    }

    /// <summary>
    /// Property marked with this attribute is the default property of the object,
    /// all entities in Ast for which mapping wasn't found will be mapped to this property.
    /// </summary>
    public class DefaultMappingAttribute : Attribute {    
    }

    /// <summary>
    /// When error occurs in annotation mapping, raw AST reprezentation of the modification
    /// will be added to property decorated with this attribute
    /// </summary>
    public class UnknownMappingAttribute : Attribute {

    }

    /// <summary>
    /// Attributes determining to which property field of array at given position shold be mapped.
    /// </summary>
    public class ArrayIndexMappingAttribute : Attribute {

        /// <summary>
        /// Public constructor
        /// </summary>
        /// <param name="position"></param>
        public ArrayIndexMappingAttribute(int position) {
            this._position = position;
        }
        
        private int _position;
        
        /// <summary>
        /// Determines the position of the source entity in array
        /// </summary>
        public int Position{
            get{return this._position;}
            set{this._position = value;}
        }
    }

    /// <summary>
    /// Determines to which property constructor argument at given position will be mapped.
    /// </summary>
    public class ConstructorIndexMappingAttribute : Attribute {
        
        /// <summary>
        /// Public constructor
        /// </summary>
        /// <param name="position"></param>
        public ConstructorIndexMappingAttribute(int position) {
            this._position = position;
        }
        
        private int _position;

        /// <summary>
        /// Determines the position of the source entity in constructor params
        /// </summary>
        public int Position{
            get{return this._position;}
            set{this._position = value;}
        }
    }

    /// <summary>
    /// Determines the group to which the particular part of annotatio will be placed
    /// </summary>
    public class AnnotationDOMGroupAttribute : Attribute {

        public AnnotationDOMGroupAttribute(string groupName) {
            this.GroupName = groupName;
        }

        public string GroupName { get; set; }
    }
}
